#include "gamesnake.h"
#include "ui_gamesnake.h"
#include "gameselect.h"
#include <QPainter>
#include <QPixmap>
#include <QIcon>
#include <QPushButton>
#include <QSound>
GameSnake::GameSnake(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::GameSnake)
{
    ui->setupUi(this);
    //设置窗口大小
    this->setFixedSize(1000,800);
    //设置窗口图标
    this->setWindowIcon(QIcon(":res/ico.png"));
    //设置窗口标签
    this->setWindowTitle("游戏大厅");
    //设置字体
    QFont font("华文行楷",25);
    //设置按钮
    QPushButton *intoBtn= new QPushButton(this);
    intoBtn->setFont(font);
    intoBtn->setText("开始游戏");
    intoBtn->setStyleSheet("QPushButton{border:0px;}");
    intoBtn->move(450,520);
    //创建另一个窗口
    GameSelect *select=new GameSelect();
    connect(intoBtn,&QPushButton::clicked,[=]{
        //关闭上个窗口
        this->close();

        select->setGeometry(this->geometry());
        select->show();
        QSound::play(":res/clicked.wav");

   });
}

GameSnake::~GameSnake()
{
    delete ui;
}

void GameSnake::paintEvent(QPaintEvent *event)
{
    //实例化一个画家
    QPainter paint(this);
    //实例化一个设备
    QPixmap pix(":res/game_hall.png");
    //进行绘画
    paint.drawPixmap(0,0,this->width(),this->height(),pix);
}

